<?php


namespace Lib\Component;


use Config\Db;

class Mysql extends \mysqli implements ComponentInterface
{
    private static $instance = null;

    private function __construct($host = null, $username = null, $passwd = null, $dbname = null, $port = null, $socket = null)
    {
        parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
    }

    /**
     * 获取单例对象
     * @return Mysql|null
     */
    public static function getInstance()
    {
        if (self::$instance == null) {
            self::$instance = new static(
                Db::MYSQL_HOST,
                Db::MYSQL_USER,
                Db::MYSQL_PASSWORD,
                Db::MYSQL_DB
            );
            self::$instance->register();
        }
        return self::$instance;
    }

    public function register()
    {
        // TODO: Implement register() method.
    }
}